home *** CD-ROM | disk | FTP | other *** search
-
- #include "includes.h"
- #include "installergui_data.h"
-
- /********************************************************************
- *
- * DESCRIPTION
- *
- * set up a simple panel, which asks the user for a number. this
- * may be done by a string gadget or (as additional feature!) as
- * a slider when the range is known. you can check for the range
- * by testing the localenv->fe_RangeSet entry and you can get
- * the lower and upper bounds by reading the localenv->fe_Range[0]
- * and localenv->fe_Range[1] entries. this function must not return
- * numbers out of range (if range is set!)
- *
- * IN: application - pointer to the private application structure
- * localenv - the local environment of the related ASKNUMBER function
- *
- * OUT: the valid (!!) number
- *
- */
-
- /********************************************************************
- *
- * STATIC
- *
- */
-
- /********************************************************************
- *
- * EXTERN
- *
- */
-
- /********************************************************************
- *
- * PUBLIC
- *
- */
-
- /********************************************************************
- *
- * CODE
- *
- */
-
- long __asm igui_AskNumber(register __a0 APTR application,
- register __a1 struct FunctionEnvironment *localenv)
- {
- #ifdef DEBUG
- DEBUG_MAKRO
- #endif
-
- {
- struct Application *app = (struct Application *) application;
-
- // the number
- long number = 0;
-
- // the mui objects
- APTR asknum, numobj;
-
- // maybe we have to create a new prompt?!
- char *prompt = (char *) localenv->fe_Prompt;
-
- // if the user specified a RANGE, then localenv->fe_RangeSet is TRUE
- // and localenv->fe_Range[0] and localenv->fe_Range[1] hold the values
- // in this case, we have to append the known "Valid range is..." string
- // to the default prompt parameter!
- if (localenv->fe_RangeSet)
- {
- long args[3];
-
- // korrect the default value, if it is out of range
- localenv->fe_Default = sav_RangeNumber(localenv->fe_Default, localenv->fe_Range[0], localenv->fe_Range[1]);
-
- args[0] = localenv->fe_Prompt;
- args[1] = localenv->fe_Range[0];
- args[2] = localenv->fe_Range[1];
-
- if (prompt = sav_StringF2(app->app_Texts[ASKNUM_RANGE], &args)) { }
- else { app->app_Error = GUIERROR_OUT_OF_MEMORY; return(number); }
- }
-
- //create the object
- asknum = GroupObject,
- Child, HVSpace,
- Child, TextObject,
- MUIA_Frame, MUIV_Frame_None,
- MUIA_Text_Contents, prompt,
- MUIA_Text_SetMin, TRUE,
- MUIA_Text_PreParse, "\33c",
- End,
- Child, numobj = StringObject,
- MUIA_Frame, MUIV_Frame_String,
- MUIA_String_Integer, localenv->fe_Default,
- MUIA_String_Accept, "0123456789",
- MUIA_String_Format, MUIV_String_Format_Center,
- End,
- Child, HVSpace,
- End;
-
- // maybee BACK (if specified) or respect the swing mode
- if (localenv->fe_Back) { guistuff_SetBackButton(app, TRUE); }
- else if (!app->app_SWING_Mode) { igui_NameCancel(app, (char *) app->app_GlobalEnv[GENV_ABORT_BUTTON]); }
-
- //
- if (guistuff_NewContent(app, asknum))
- {
- // we have to wait, until the correct number was entered!
- while(TRUE)
- {
- igui_WaitApp(app);
- if (igui_QuitApp(app)) { break; }
- else
- {
- // get the number an check for its range (if we have to)!
- GetAttr(MUIA_String_Integer, numobj, (ULONG *) &number);
- if (localenv->fe_RangeSet)
- {
- if (number < localenv->fe_Range[0] || number > localenv->fe_Range[1]) { DisplayBeep(NULL); }
- else { break; }
- }
- }
- }
- }
- else { /* NO GUI OBJECT */ }
-
- //
- if (localenv->fe_Back) { guistuff_SetBackButton(app, FALSE); }
-
- igui_EmptyPanel(app);
- return(number);
- }
- }
-
-